package com.principle.composite;

import java.util.ArrayList;
import java.util.List;

//University就是 Composite，可以管理 College
public class University extends OrganizationComponent{
    List<OrganizationComponent> organizationComponentList=new ArrayList<>();

    public University(String name, String des) {
        super(name, des);
    }
    //重写 add
    @Override
    protected void add(OrganizationComponent organizationComponent) {
        organizationComponent.add(organizationComponent);
    }
    //重写 remove
    @Override
    protected void remove(OrganizationComponent organizationComponent) {
        organizationComponent.remove(organizationComponent);
    }

    @Override
    public String getName() {
        return super.getName();
    }

    @Override
    public String getDes() {
        return super.getDes();
    }
    //print 方法，就是输出 University包含的学院
    @Override
    protected void print() {
        System.out.println("-----------"+getName()+"-----------");
        //遍历organizationComponentList
        for (OrganizationComponent organizationComponent : organizationComponentList) {
            organizationComponent.print();
        }
    }
}
